package com.info33.platform.system.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.info33.platform.common.mvc.entity.BaseEntity;
import com.info33.platform.system.dto.SysConfigDTO;
import com.info33.platform.system.dto.SysTenantDTO;
import com.info33.platform.system.dto.SysUserDTO;
import com.info33.platform.system.util.enums.UserTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * 系统 - 租户
 *
 * @author admin
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class SysTenant extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @NotNull(groups = {SysTenantDTO.SaveTenant.class, SysTenantDTO.UpdateTenant.class}, message = "租户类型不能为空")
    @ApiModelProperty(value = "租户类型")
    private UserTypeEnum type;

    @NotEmpty(groups = {SysTenantDTO.SaveTenant.class, SysTenantDTO.UpdateTenant.class}, message = "租户名称不能为空")
    @ApiModelProperty(value = "租户名")
    private String name;

    @NotEmpty(groups = {SysTenantDTO.SaveTenant.class, SysTenantDTO.UpdateTenant.class}, message = "租户信息不能为空")
    @ApiModelProperty(value = "租户信息")
    private String info;

    @NotNull(groups = {SysTenantDTO.SaveTenant.class, SysTenantDTO.UpdateTenant.class}, message = "访问类型不能为空")
    @ApiModelProperty(value = "访问类型（1域名2IP）")
    private Integer urlType;

    @NotEmpty(groups = {SysUserDTO.PasswordLogin.class,
            SysTenantDTO.SaveTenant.class,
            SysConfigDTO.PcConfig.class,
            SysTenantDTO.UpdateTenant.class}, message = "域名不能为空")
    @ApiModelProperty(value = "域名/ip")
    private String url;

    @NotNull(groups = {SysTenantDTO.SaveTenant.class, SysTenantDTO.UpdateTenant.class}, message = "是否启动不能为空")
    @ApiModelProperty(value = "是否启动")
    private Boolean activate;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "原申请信息 id【app_tenant_apply】")
    private Long applyId;

    @ApiModelProperty(value = "是否具有 app 应用")
    private Boolean hasApp;

}